package com.hq.service;

import com.hq.bean.City;
import com.hq.bean.Student;
import com.hq.bean.Teacher;
import com.hq.bean.Users;
import com.hq.dao.StudentDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class StudentServiceImpl implements StudentService{
    @Resource
    private StudentDao dao;

    @Override
    public List<Student> list(Map map) {
        return dao.list(map);
    }

    @Override
    public List<Teacher> teacher() {
        return dao.teacher();
    }

    @Override
    public List<City> city(Integer pid) {
        return dao.city(pid);
    }

    @Override
    public Users login(Users users) {
        return dao.login(users);
    }

    @Override
    public int addRegister(Users users) {
        return dao.addRegister(users);
    }

    @Override
    public int add(Student student, Integer[] tids) {
        HashMap map = new HashMap();
        map.put("sid",student.getSid());
        map.put("tids",tids);
        dao.addMi(map);
        return dao.addStu(student);
    }

    @Override
    public int del(Integer sid) {
        dao.delMi(sid);
        int i = dao.delStu(sid);
        return i;
    }

    @Override
    public Map getBySid(Integer sid) {
        return dao.getBySid(sid);
    }

    @Override
    public int upd(Student student, Integer[] tids) {
        dao.delMi(student.getSid());
        HashMap map = new HashMap();
        map.put("sid",student.getSid());
        map.put("tids",tids);
        dao.addMi(map);
        return dao.upStu(student);
    }

    @Override
    public int yz(String uname) {
        return dao.yz(uname);
    }

    @Override
    public int dels(String sid) {
        dao.delMis(sid);
        return dao.dels(sid);
    }
}
